<?php 
	//by hashman
	session_start();
	if (!isset($_SESSION['username'])) {
		echo "<script language='javascript'>";
		echo "alert('You have no permission to read this page!');";
		echo "history.back();";
		echo "</script>";
		header("location:../../login.php");
	}
	else{
		require_once('../../Model/MySQL.php');
		require('../../Controller/search_controller.php');
		
		$id = $_GET["id"];
		$whoami = $_SESSION['uid'];
		$control = new search_controller();
		$target= $_POST['searchPeople'];
		$result=$control->search($target);
		echo $result[0];
		
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>搜尋</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Le styles -->
    <link href="../../CSS/bootstrap/css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
      body {
        padding-top: 60px;
        padding-bottom: 40px;
      }
    </style>
    <link href="../../CSS/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">

    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- Fav and touch icons -->
    <link rel="shortcut icon" href="../../CSS/bootstrap/ico/favicon.ico">
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="../../CSS/bootstrap/ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="../../CSS/bootstrap/ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="../../CSS/bootstrap/ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="../../CSS/bootstrap/ico/apple-touch-icon-57-precomposed.png">
  </head>

  <body>

    <div class="navbar navbar-inverse navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          <a class="brand" href="../../views/index.php?id=<?php echo $whoami; ?>">FaceTech</a>
          <div class="nav-collapse collapse">
            <ul class="nav">
              <li class="active"><a href="../../views/index.php?id=<?php echo $whoami; ?>"><i class="icon-home icon-white"></i>Home</a></li>
              <li class="active"><a href="../../views/logout.php"><i class="icon-off icon-white"></i>Logout</a></li>
              <li class="active"><a href="../friends/requests.php"><i class="icon-user icon-white"></i>好友邀請確認</a></li>             		
            </ul>
			</div><!--/.nav-collapse -->
        </div> 
      </div>
    </div>
	
	<?php 
	if($target!="" && mysql_num_rows($result)!=0)	{

		echo '<div class="container">';
		echo '<h1><p>搜尋結果:</p></h1>';
		echo '<div class="hero-unit">';
	
		echo '<ul class="thumbnails">';
		echo '<li class="span4">';
		echo '<li class="active">';
		echo '<div class="thumbnail">';
		echo '<h1>';
		
		while($results=mysql_fetch_row($result))	{
			echo '<a href="../index.php?id='.$results[0].' ">';
			echo '<li class="active"><img class="img-rounded" src="../../'.$results[4].'"  height="64" width="64" ></i></li>';
	     	echo '<li class="active"><p><p align=center>'.$results[3].'</p>';
			echo '</a>';
			
		}
		
		echo '</h1>';
		echo '</li>';
		echo '</li>';
		echo '</ul>';
		echo '</div>';
		echo '<div class="row-fluid">';
		echo '<div class="span4">';
	}
	else	{
		echo '<h1><p>無符合結果</p></h1>';
	}
	?>
	
	<!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="../../CSS/bootstrap/js/jquery.js"></script>
    <script src="../../CSS/bootstrap/js/bootstrap-transition.js"></script>
    <script src="../../CSS/bootstrap/js/bootstrap-alert.js"></script>
    <script src="../../CSS/bootstrap/js/bootstrap-modal.js"></script>
    <script src="../../CSS/bootstrap/js/bootstrap-dropdown.js"></script>
    <script src="../../CSS/bootstrap/js/bootstrap-scrollspy.js"></script>
    <script src="../../CSS/bootstrap/js/bootstrap-tab.js"></script>
    <script src="../../CSS/bootstrap/js/bootstrap-tooltip.js"></script>
    <script src="../../CSS/bootstrap/js/bootstrap-popover.js"></script>
    <script src="../../CSS/bootstrap/js/bootstrap-button.js"></script>
    <script src="../../CSS/bootstrap/js/bootstrap-collapse.js"></script>
    <script src="../../CSS/bootstrap/js/bootstrap-carousel.js"></script>
    <script src="../../CSS/bootstrap/js/bootstrap-typeahead.js"></script>

  </body>
</html>
<?php 
	
	
	}
?>